package com.lx.lib.utils;

import android.content.Context;
import android.os.Environment;
import android.text.TextUtils;

import java.io.File;

/**
 * 类说明：项目文件夹管理
 * Created by liuxiong on 2019/3/25.
 */

public class FileManager {

    private FileManager(){}

    private static  FileManager instance;

    private String rootPath;

    private String mString;

    Context context;

    public static FileManager getInstance(){
        if(instance==null){
            synchronized (FileManager.class){
                if(instance==null){
                    instance=new FileManager();
                }
            }
        }
        return instance;
    }

    /**
    * 方法说明:  项目文件夹初始化
    * @param context 全局上下文
    * created by liuxiong on 2019/3/25 14:48
    */
    public void init(Context context){
        context=context.getApplicationContext();
        String absolutePath = Environment.getExternalStorageDirectory().getAbsolutePath();
        if(TextUtils.isEmpty(absolutePath)){
            absolutePath=context.getFilesDir().getAbsolutePath();
        }

        rootPath=absolutePath+ File.separator+"MyLib";
    }

    public String getRootPath(){
        return rootPath;
    }
}
